/*
 * Copyright (c) 2013, Juergen Bocklage-Ryannel, Johan Thelin
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of the editors nor the
 *       names of its contributors may be used to endorse or promote products
 *       derived from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

// M1>>
import QtQuick 2.5
/*
当创建一个连接元素（Connection element）未指定目标属性时，默认的属性是父
对象。这意味着需要显式的设置NULL来避免捕获来自父对象的信号，直到目标被
设置。这种行为使得基于连接元素（Connection element）创建自定义信号处理组
件成为可能。使用这种方式可以将信号的处理代码封装和再使用。

在下面这个例子中，闪烁组件能够被放在任何的鼠标区域（MouseArea）中.点击后
会触发动画，导致父对象闪烁。在同一个鼠标区域（MouseArea）的实际任务被触
发时也可以被调用。这从实际的动作中，分离了标准的用户反馈，闪烁。
*/

Rectangle {
    id: root
    width: 400; height: 300
    color: "blue"
    // A background flasher that flashes the background of any parent MouseArea
    MouseArea {
        id: rightMouseArea
        anchors.fill: parent

        Connections {
            id: con
            onClicked: {
                print('12121')
                // Automatically targets the parent
                activeClickedAnimation.start();
            }
        }
        SequentialAnimation {
            id: activeClickedAnimation
            // 先将透明度设置为1
            PropertyAction {
                target: con.target.parent
                property: "opacity"
                value: 1
            }
            // 再慢慢（3000）变化为0
            PropertyAnimation {
                target: con.target.parent
                property: "opacity"
                to: 0
                duration: 3000
            }
        }
    }
}

// <<M1
